package com.stylefeng.guns.modular.model.controller;

import com.stylefeng.guns.core.base.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import com.stylefeng.guns.modular.system.model.Weixininfo;
import com.stylefeng.guns.modular.model.service.IWeixininfoService;

/**
 * bashi控制器
 *
 * @author fengshuonan
 * @Date 2018-07-31 09:21:33
 */
@Controller
@RequestMapping("/weixininfo")
public class WeixininfoController extends BaseController {

    private String PREFIX = "/model/weixininfo/";

    @Autowired
    private IWeixininfoService weixininfoService;

    /**
     * 跳转到bashi首页
     */
    @RequestMapping("")
    public String index() {

        return PREFIX + "weixininfo.html";
    }

    /**
     * 跳转到添加bashi
     */
    @RequestMapping("/weixininfo_add")
    public String weixininfoAdd() {

        return PREFIX + "weixininfo_add.html";
    }

    /**
     * 跳转到修改bashi
     */
    @RequestMapping("/weixininfo_update/{weixininfoId}")
    public String weixininfoUpdate(@PathVariable Integer weixininfoId, Model model) {
        Weixininfo weixininfo = weixininfoService.selectById(weixininfoId);
        model.addAttribute("item",weixininfo);
        LogObjectHolder.me().set(weixininfo);
        return PREFIX + "weixininfo_edit.html";
    }

    /**
     * 获取bashi列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return weixininfoService.selectList(null);
    }

    /**
     * 新增bashi
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(Weixininfo weixininfo) {
        weixininfoService.insert(weixininfo);
        return SUCCESS_TIP;
    }

    /**
     * 删除bashi
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer weixininfoId) {
        weixininfoService.deleteById(weixininfoId);
        return SUCCESS_TIP;
    }

    /**
     * 修改bashi
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(Weixininfo weixininfo) {
        weixininfoService.updateById(weixininfo);
        return SUCCESS_TIP;
    }

    /**
     * bashi详情
     */
    @RequestMapping(value = "/detail/{weixininfoId}")
    @ResponseBody
    public Object detail(@PathVariable("weixininfoId") Integer weixininfoId) {
        return weixininfoService.selectById(weixininfoId);
    }
}
